-- 战绩榜 
local GuildWarGuildScoreCell = app.mvc.createListViewCell(...)
--data =
function GuildWarGuildScoreCell.create(node)
    local sprite = GuildWarGuildScoreCell.extend(node or cc.CSLoader:createNode(Res.CSGuildWarGuildScoreCell))
    if node == nil then
        ccui.Helper:doLayout(sprite)
    end
    sprite:init()
    return sprite
end


function GuildWarGuildScoreCell:init(data)
    self.super.init(self, data)
    self:setContentSize( self._ui.Panel:getContentSize() )
    self:refresh()

end

function GuildWarGuildScoreCell:refresh()
    if not self._data then
        return
    end
    local data = self._data
    
    local rankIndex = 1
    if self._cellModel then
        rankIndex = self._cellModel:getIndex()
    end

    self._ui.num:setString(rankIndex)
    self._ui.guild:setString(data:getGuildName())
    self._ui.server:setString(data:getServerName())
    self._ui.record:setString(string.format(L("CSGuildWarFightResultTip1"), data:getWinCount(), data:getLoseCount()))
    self._ui.fraction:setString(data:getScore())

 
    if rankIndex <= 4 then
        self._ui.bg:loadTexture(Res.CSGuildWarGuildScoreBg2, 1)
        self._ui.qc:setString(string.format(L("CSGuildWarGuildScoreStr1"), 1, 4))
    elseif rankIndex <= 8 then
        self._ui.bg:loadTexture(Res.CSGuildWarGuildScoreBg3, 1)
        self._ui.qc:setString(string.format(L("CSGuildWarGuildScoreStr1"), 5, 8))
    elseif rankIndex <= 12 then
        self._ui.bg:loadTexture(Res.CSGuildWarGuildScoreBg4, 1)
        self._ui.qc:setString(string.format(L("CSGuildWarGuildScoreStr1"), 9, 12))
    elseif rankIndex <= 16 then
        self._ui.bg:loadTexture(Res.CSGuildWarGuildScoreBg5, 1)
        self._ui.qc:setString(string.format(L("CSGuildWarGuildScoreStr1"), 13, 16))
    else
        self._ui.bg:loadTexture(Res.CSGuildWarGuildScoreBg1, 1)
        self._ui.qc:setString("/")
    end
    
end


return GuildWarGuildScoreCell